<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
div{width:200px; height:200px; margin:20px; background:yellow; float:left; filter:alpha(opacity:30); opacity:0.3; border:1px solid #000;}
</style>
<script>
window.onload=function()
{
	var oDiv1=document.getElementById('div1');
	
		oDiv1.onmouseover=function()
		{
			startMove(this,'opacity',400);
		}
		oDiv1.onmouseout=function()
		{
			startMove(this,'opacity',200);
		};
		
		
};

//var alpha=30;
function getStyle(obj,name)
{
	if(obj.currentStyle)
	{
		return obj.currentStyle[name];
	}
	else
	{
		return getComputerStyle(obj,false)[name];
	}
	
}

function startMove(obj,attr,iTarget)
{
	clearInterval(obj.timer);
	obj.timer=setInterval(function(){
		var car=0;
		if(attr=='opacity')
		{
			cur=Math.round(parseFloat(getStyle(obj,attr))*100);
		}
		else
		{
			cur=parseInt(getStyle(obj,attr));
		}
		
		var speed=(iTarget-cur)/6;
		speed=speed>0?Math.ceil(speed):Math.floor(speed);
		
		if(iTarget==cur)
		{
			clearInterval(obj.timer);
		}
		else
		{
			if(attr=='opacity')
			{
				obj.style.fliter='alpha(opacity:'+(cur+speed)+')';
				obj.style.opacity=(cur+speed)/100;
			}
			else
			{
				obj.style[attr]=cur+speed+'px';
			}
		}
		},30);
}
</script>
</head>

<body>
<div id="div1"></div>

</body>
</html>
